<template>
<div>
  <el-card v-if="item.feedbackContent!=null" style="width: 600px;margin: 10px auto" :key="item.id" v-for="item in complainingArr" class="box-card">
    <span>以下是根据您于{{item.created}}</span><br>
    <span>对{{item.hotelName}}所提交的投诉反馈</span>
    <el-divider></el-divider>
    <p>{{item.feedbackContent}}</p>
  </el-card>
  <el-empty v-if="showEmpty" :image-size="200"></el-empty>
</div>
</template>

<script>
export default {
  data(){
    return{
      complainingArr:[],
      showEmpty:true
    }
  },
  methods:{
    loadUserComplainingList(){
      let url = 'http://localhost:9580/hotelComplains/user/getHotelComplainingListById';
      console.log("url"+url);
      this.axios
          .create({'headers':{'Authorization':localStorage.getItem('jwt')}})
          .get(url).then((response) =>{
        let responseBody=response.data;
        this.complainingArr=responseBody.data;
        console.log(this.complainingArr);
        for (let item of this.complainingArr) {
          if (item.feedbackContent!=null){
            this.showEmpty=false;
          }
          item.created=item.created.replace(/[T]+/g,' ');
        }
      })
    }
  },
  mounted() {
    this.loadUserComplainingList();
  }
}
</script>

<style scoped>

</style>